﻿using System.Text.Json;

namespace ResultCollector
{
    internal class DiceSettings
    {
        private readonly FileInfo settingsFile;
        private readonly FileInfo readmeFile;
        public DiceSettings(string baseDir)
        {
            const string settingsPath = "CylindricalDice_Data/StreamingAssets/settings.json";
            const string readmePath = "CylindricalDice_Data/StreamingAssets/settings-readme.txt";
            settingsFile = new FileInfo(Path.GetFullPath(settingsPath, baseDir));
            readmeFile = new FileInfo(Path.GetFullPath(readmePath, baseDir));
        }

        public float Scale { get; set; }
        public float DiameterToHeight { get; set; }

        public int Count { get; set; }
        public Vector3 RegionStarting { get; set; }
        public Vector3 RegionEnding { get; set; }

        public float RecordingTime { get; set; }
        public float LastingTime { get; set; }

        public string? OutputFile { get; set; }

        public void Write()
        {
            const string readmeContent = "I know what I am doing. Please load `settings.json` at the next run.";
            File.WriteAllText(settingsFile.FullName, JsonSerializer.Serialize(this));
            File.WriteAllText(readmeFile.FullName, readmeContent);
        }
    }
}
